﻿using CustomControls.DrawerMenu.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;

namespace CustomControls.DrawerMenu
{
    public class MenuItemDataTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item != null)
            {
                var fe = container as FrameworkElement;
                MenuItemModel menuItem = item as MenuItemModel;
                if (menuItem.Data != null)
                {
                    return fe.FindResource("MenuItemsDataTemplate") as DataTemplate;
                }
                else
                {
                    return fe.FindResource("MenuItemDataTemplate") as DataTemplate;
                }
            }
            return null;
        }
    }

}
